package com.ezia.coreservices.charging.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.ezia.coreservices.charging.service.ChargingLocationSearchService;
import com.ezia.coreservices.charging.utils.ResultMsg;


@RestController
public class ChargingLocationSearchController {

	@Autowired
	private ChargingLocationSearchService chargingService;
	
	//按照名称查询充电站信息
    @ResponseBody
    @RequestMapping(value = "/{version}/charging/vehicle/external/search/findbypoiname", method = RequestMethod.POST,
    		produces="application/json;charset=UTF-8")
    public ResultMsg findByPOIName(@PathVariable("version") String version, 
    		@RequestParam(value = "keyword", required = true) String keyword,
    		@RequestParam(value = "areaCode", required = false) String areaCode,
    		@RequestParam(value = "pageSize", required = false) Integer pageSize,
    		@RequestParam(value = "pageNo", required = false) Integer pageNo,
    		@RequestParam(value = "scope", required = true) String scope,
    		@RequestParam(value = "filter", required = false) String filter,
    		@RequestParam(value = "coordType", required = true) Integer coordType, 	
    		
    		@RequestBody Map<String,Object> userInfo
    		) {
		return chargingService.findByPOIName(keyword, areaCode, pageSize, pageNo, scope, filter,
				coordType, userInfo);
	}
	
	//获取位置附近的充电场信息（T_API,M_API）
	@ResponseBody
	@RequestMapping(value = "/{version}/charging/vehicle/external/search/findbylocation", method = RequestMethod.POST,
			produces="application/json;charset=UTF-8")
	public ResultMsg findByLocation(@PathVariable("version") String version,
			@RequestParam(value = "scope", required = true) String scope,
			@RequestParam(value = "filter", required = false) String filter,
			@RequestParam(value = "coordType", required = true) Integer coordType,
			@RequestParam(value = "pageSize", required = false) Integer pageSize,
			@RequestParam(value = "pageNo", required = false) Integer pageNo,
			@RequestParam(value = "latitude", required = true) String latitude,
			@RequestParam(value = "longitude", required = true) String longitude,
			@RequestParam(value = "radius", required = false) String radius,
			
			@RequestBody Map<String,Object> userInfo
			) {
		return chargingService.findByLocation(scope, filter, coordType, pageSize, pageNo, latitude, longitude, radius, userInfo);
	}
	
	//查询充电站的动态信息接口
	@ResponseBody
	@RequestMapping(value = "/{version}/charging/vehicle/external/search/getdynamicinfo", method = RequestMethod.POST,
			produces="application/json;charset=UTF-8")
	public ResultMsg getDynamicInfo(@PathVariable("version") String version,
			@RequestParam(value = "CPO_id", required = true) String CPO_id,
			@RequestParam(value = "stationId", required = true) String stationId,
			
			@RequestBody Map<String,Object> userInfo
			) {
		
		
		return chargingService.getDynamicInfo(CPO_id, stationId, userInfo);
	}
	
	
	
	
}